﻿#ifndef FUNTESTWIDGET_H
#define FUNTESTWIDGET_H

#include <QWidget>
#include <QButtonGroup>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QCheckBox>
#include "quiqss.h"
#include "define.h"
#include "qcustomplot.h"
#include "capcontroldefine.h"





class QFunTestWidget : public QWidget
{
    Q_OBJECT
public:
    explicit QFunTestWidget(int i32AxiNo,QWidget *parent = nullptr);

    void InitUI();

    QWidget* createParamWidget();

    void setParamInfo();

    void setButtonStyleSheet(QPushButton* pBtn);

    void setHBoxHide(QString sObjectName,bool bHid);

    void sendParamData();

    void setPlotStyle(QCustomPlot* pPlot,QString xName,QString yName);

    void rcvFrameData(st_rcvdata rcvdata);

    void saveDataToFile();

    void caclData();

    void plotRcvData();

    void writeDataToFile(QString str);

    void InitTableWidget();

    void showStatus();


signals:

    void signal_startTest(int i32Axis,int workmode,int data,int data1);
    void signal_set_thresholdparam(int i32Aixs,int cmdid,int i32value,int datalen);


public slots:
    void onWorkModeChange(int Index);
    void onStartTest();

    void onSaveDataBtnClick();

private:
    QButtonGroup* _pWorkModeBtnGroup;

    QLabel* _pParamNameLabel[4];
    QLineEdit* _pParamEdit[4];
    QPushButton* _pStartTestBtn;

    QCustomPlot* _pCurrentPlot;

    QCheckBox* _pSaveDataCheckBox;

    QPushButton* _pCalcBtn;


    QMap<int,st_workmodeParam> _workModeParamMap;

    int _i32AxisSelect;

    int _i32CurrentWorkMode;
    st_rcvdata _rcv_capdata;

    int _i32FrameCnt;

    float _lfAziSetdata;
    float _lfPitchSetdata;

    float _lfAziResponsedata;
    float _lfPitchResponsedata;

    bool _bStartTest;
    bool _bCaclData;

    QVector<double> _xdatalist;
    QVector<double> _ydatalist[2];

    QVector<double> _ycacldatalist[2];


    QTimer* _pPlotDataTimer;

    QLabel* _pShowDataLabel;
    QTableWidget* _pParamShowTableWidget;

    bool _bStartSaveData;

    QFile m_savefile;

    int _i32SaveFrameCnt;

    QString m_sSaveDataInfo;


    //保存数据时使用变量
    float lfAziSpeedResponse;
    float lfAziSpeedSet;
    float lfPitchSpeedResponse;
    float lfPitchSpeedSet;
    float lfAziQResponsedata;
    float lfAziQSetdata;
    float lfPitchQResponsedata;
    float lfPitchQSetdata;

     float lfAziCurrentA;
     float lfAziCurrentC;
     float lfPitchCurrentA;
     float lfPitchCurrentC;

     float lfAziPosResponse;
     float lfAziPosSet;
     float lfPitchPosResponse;
     float lfPitchPosSet;

     int _i32ShowCnt;


};

#endif // GROUNDTESTWIDGET_H
